package com.example.novelstory.service.dxy;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.novelstory.dao.dxy.AdvertDao;
import com.example.novelstory.entity.Advert;
import java.util.List;
import org.springframework.stereotype.Service;

@Service
public class AdvertServicelmpl extends ServiceImpl<AdvertDao,Advert> {
//    @Autowired
//    AdvertDao advertDao;
//
//    @Override
    public List<Advert> findadvertAll() {
//        List<Advert> all = advertDao.findadvertAll();
        return list();
    }

//    @Override
    public Boolean addadvertInfo(Advert advert) {
//        int addadvertInfo = advertDao.addadvertInfo(advertid,advertname,advertlink);
//        if (addadvertInfo == 1) {
//            List<Advert> all = advertDao.findadvertAll();
//            return all;
//        } else {
            return save(advert);

        }



//    @Override
    public Boolean deleteadvertInfo(int advertid) {
//        int useradvertInfo = advertDao.deleteadvertInfo(advertid);
//        if (useradvertInfo == 1) {
//            List<Advert> all = advertDao.findadvertAll();
//            return all;
//        } else {
            return removeById(advertid);

        }

//    }

//    @Override
    public Boolean updeteadvertInfo(Advert advert)   {
//        int updeteadvertInfo = advertDao.updeteadvertInfo(advertid,advertname,advertlink);
//        if (updeteadvertInfo == 1) {
//            List<Advert> all = advertDao.findadvertAll();
//            return all;
//        } else {
//            return updateById(advert);
//        }
        QueryWrapper queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("advertname",advert.getAdvertname());
        return update(queryWrapper);
    }
}
